package com.ougy.reshop.action;

import java.sql.Timestamp;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.ougy.reshop.service.ISAccessory;
import com.ougy.reshop.service.ISAlbum;
import com.ougy.reshop.service.ISGoodsClass;
import com.ougy.reshop.service.ISPublish;
import com.ougy.reshop.service.ISRegion;
import com.ougy.reshop.service.ISUser;
import com.ougy.reshop.util.Notice;

public class BaseAction extends ActionSupport {
	private static final long serialVersionUID = -1170067112876395839L;
	protected Logger logger = Logger.getLogger(getClass());
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected Notice notice = new Notice();
	protected Map session = ActionContext.getContext().getSession();
	protected ISUser sUser;
	protected ISPublish sPublish;
	protected ISAlbum sAlbum;
	protected ISAccessory sAccessory;
	protected ISGoodsClass sGoodsClass;
	protected ISRegion sRegion;
	
	public ISRegion getSRegion() {
		return sRegion;
	}
	@Resource
	public void setSRegion(ISRegion region) {
		sRegion = region;
	}
	public ISGoodsClass getSGoodsClass() {
		return sGoodsClass;
	}
	@Resource
	public void setSGoodsClass(ISGoodsClass goodsClass) {
		sGoodsClass = goodsClass;
	}
	public ISAccessory getSAccessory() {
		return sAccessory;
	}
	@Resource
	public void setSAccessory(ISAccessory accessory) {
		sAccessory = accessory;
	}
	public ISAlbum getSAlbum() {
		return sAlbum;
	}
	@Resource
	public void setSAlbum(ISAlbum album) {
		sAlbum = album;
	}

	public ISPublish getSPublish() {
		return sPublish;
	}

	@Resource
	public void setSPublish(ISPublish publish) {
		sPublish = publish;
	}

	public ISUser getSUser() {
		return sUser;
	}

	@Resource
	public void setSUser(ISUser user) {
		user.setSession(session);
		sUser = user;
	}

	public Timestamp getTimestamp() {
		return new Timestamp(System.currentTimeMillis());
	}

	public Notice getNotice() {
		return this.notice;
	}

	public void setNotice(Notice notice) {
		this.notice = notice;
	}

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}

	public String getUuid() {
		return UUID.randomUUID().toString().replaceAll("-", "");
	}
}
